#ifndef PLAYER_REGION_H_
#define PLAYER_REGION_H_

// INCLUDES //
#include "region.h"
#include "object.h"
#include "card/deck.h"
#include "graphics/surface.h"
#include <string>
//////////////

// CONSTANTS //
#define BAR_LEFT_INDENT			5
#define BAR_RIGHT_INDENT		10
#define BAR_HEIGHT				10
#define BAR_SPACING				5
///////////////

/**
* A region that shows the player's name, health, and card count.
* 
* @author dfoelber
**/
class PlayerRegion : public Region
{
public:
	/**
	* Constructor
	**/
	PlayerRegion();
	
	/**
	* Destructor
	**/
	virtual ~PlayerRegion();
	
	/**
	* Sets the region's boundary.
	* 
	* Overridden from Region.
	* 
	* @param x The boundary's X coordinate
	* @param y The boundary's Y coordinate
	* @param width The boundary's width
	* @param height The boundary's height
	**/
	virtual void SetBoundary( int x, int y, int width, int height );
	
	/**
	* Notify the region of an event.
	* 
	* Overridden from Region.
	* 
	* @param event The event that happened
	* @return If the region used the event
	**/
	virtual bool ProcessEvent( SDL_Event event );
	
	/**
	* Notifies of time passing.
	* 
	* Overridden from Region.
	* 
	* @param The amount of time, in milliseconds, that passed since the last call
	**/
	virtual void TimePassed( int ms );
	
	/**
	* Renders the objects on the background
	* 
	* Overridden from Region.
	**/
	virtual void Render();
	
	/*
	* Sets the player's name.
	* 
	* @param name The new player name
	**/
	void SetPlayerName( string name );
	
	/*
	* Sets the player's health.
	* 
	* @param health The player's health
	**/
	void SetHealth( int health ) { playerHealth = health; }
	
	/*
	* Gets the player's health.
	* 
	* @return The player's health
	**/
	int GetHealth() { return playerHealth; }
	
	/*
	* Sets the player's total health.
	* 
	* @param health The player's total health
	**/
	void SetTotalHealth( int health ) { totalHealth = health; }
	
	/*
	* Gets the player's total health.
	* 
	* @return The player's total health
	**/
	int GetTotalHealth() { return totalHealth; }
	
	/*
	* Sets the player's deck size.
	* 
	* @param deck The player's deck size
	**/
	void SetDeckSize( int deck ) { playerDeck = deck; }
	
	/*
	* Gets the player's deck size.
	* 
	* @return The player's deck size
	**/
	int GetDeckSize() { return mainDeck->GetSize(); }
	
	/*
	* Sets the player's possible deck size.
	* 
	* @param deck The player's possible deck size
	**/
	void SetTotalDeck( int deck ) { totalDeck = deck; }
	
	/*
	* Gets the player's possible deck size.
	* 
	* @return The player's possible deck size
	**/
	int GetTotalDeck() { return totalDeck; }
	
	/*
	* Loads an initial set of cards into the deck.
	* 
	* @param cards The cards to add.
	**/
	void LoadCards(vector<CardInfo*> cards);
	
	/*
	* Pops the top card from the deck and returns it.
	* 
	* @return The top card.
	**/
	Card* PopCard();
	
	/*
	* Discards the card, adding it in the discard pile.
	* 
	* @param card The cards to discard.
	**/
	void Discard(CardInfo* card) { discardDeck->Add(card); }
	
private:
	/*
	* Calculates the player's health as a percentage.
	* 
	* @return The player's health.
	**/
	int GetPercentHealth();
	
	/*
	* Calculates the player's deck size as a percentage.
	* 
	* @return The player's deck size.
	**/
	int GetPercentDeck();
	
private:
	/// The object for the player's name
	Object*			name; 
	/// The object for the player's health
	Object*			health;
	/// The object for the player's deck
	Object*			deck;
	/// The player's total health
	int				totalHealth;
	/// The player's health
	int				playerHealth;
	/// The current player health, as show by the region (as a percentage)
	double			currentHealth;
	/// If the region should show the player's health
	bool			showHealth;
	/// The player's total possible deck size
	int				totalDeck;
	/// The player's deck (as a percentage)
	int				playerDeck;
	/// The current player deck, as show by the region (as a percentage)
	double			currentDeck;
	/// If the region should show the player's deck size
	bool			showDeck;
	/// The player's deck
	Deck*			mainDeck;
	/// The discard deck
	Deck*			discardDeck;
};

#endif /*PLAYER_REGION_H_*/
